package peer.player;

import java.util.prefs.Preferences;

public class SaveLastPlayThread implements Runnable{
	Thread mainThread;
	static Preferences userPrefs;
	static long lastSaveTime=0;
	SaveLastPlayThread(){
		mainThread=new Thread(this);
		mainThread.start();
	}
	public void run() {
		userPrefs = Preferences.userRoot().node("lightplayer/lastplay");
	}
	
	static String getLastPlayPath(){
		return userPrefs.get("path", "");
	}
	
	static int getLastPlayTime(){
		return userPrefs.getInt("time", 0);
	}
	
	static void trySaveLastplayTime(String path,int time){
		if(System.currentTimeMillis()-lastSaveTime>900){
			userPrefs.put("path", path);
			userPrefs.putInt("time", time);
			lastSaveTime=System.currentTimeMillis();
		}
	}

}
